home *** CD-ROM | disk | FTP | other *** search
- #ifndef lint
- static char SccsId[]= "@(#)@(#)dynamic_sd.c 1.19 V1.19 3/13/95";
- #endif
- /*
- | file name - dynamic_sd.c
- |=======================================================================
- |
- | This example program loads in a single view that contains two
- | subdrawing objects. After setting up some event handling for
- | menu and two input objects that appear at the bottom of the
- | view, it creates three linked lists which contain (among other
- | things) the data source variables from the main view and the
- | two subdrawing views. The user can then pick on the text toggle
- | menus at the left that toggle between 'Local' and 'Global.'
- | This will specify what kind of mapping there is for each of the
- | data source variables. The user can then select 'Run' to animate
- | the drawings. There are digit graphs for each of the data source
- | variables so the user can monitor the actual values and see how
- | they change in relation to the mappings. 'Restart' will reset
- | the mappings and start from the beginning again, 'Quit' ends
- | the program.
- |
- |=======================================================================
- */
- #include <windows.h>
- /*
- * DV-Tools header files
- */
- #include "std.h" /* <stdio.h> etc., scalar & macro definitions */
- #include "dvstd.h" /* public types & constants */
- #include "dvtools.h" /* constants used by T routines */
- #include "dvGR.h" /* constants used by window mgt & GR routines */
- #include "VOstd.h" /* constants used by VO & VOob routines */
- #include "Tfundecl.h" /* T routines (screens, drawports & views) */
- #include "VOfundecl.h" /* VO routines (objects) */
- #include "VUerfundecl.h" /* VUer routines (event handling routines) */
- #include "VPfundecl.h" /* VP routines (put info for dgp & vdp) */
-
- /* Constants */
- #define DVPATH (char *)NULL
- #define DISPFORMS_STB (char *)NULL
- #define DVDEVICE (char *)NULL
- #define DVCOLORTABLE (char *)NULL
- #define VIEW_NAME "dyn_sd.v"
- #define SCREEN_VIEWPORT (RECTANGLE *)NULL
- #define QUIT_BUTTON 1
- #define RESTART_BUTTON 2
- #define RUN_BUTTON 3
- #define START_INPUT 1
- #define END_INPUT 2
- #define INITIAL_DQ_SIZE 6
- #define ITER_BUFSIZE 10
-
- #define TERMINATE 0xffff /* must be different from INPUT_* values */
-
- /* Structure used to create a linked list of data source variables */
- typedef struct lnklst
- {
- char *dsname; /* Data source name */
- DSVAR dsvar; /* Data source variable */
- char *dsvname; /* Data source variable name */
- float mapped; /* If YES, dsvar is mapped to top view */
- float oldmap; /* Used to test if mapping has changed */
- struct lnklst *next; /* Pointer to next item in list */
- } LNKLST;
-
-
- /* Globals */
- int MainSelection;
- VIEW MainView;
- char start_iter[ITER_BUFSIZE], end_iter[ITER_BUFSIZE];
- DV_POINT StartFocus, EndFocus;
- OBJECT MainScreen, MainDrawing, Sd1, Sd2, StartTxtInp, EndTxtInp;
- OBJECT StartBorder, EndBorder;
- LNKLST *MainDsvList, *Sd1DsvList, *Sd2DsvList;
- DRAWPORT MainDp;
-
- /* Global forward function declarations */
- ADDRESS GetDsVars V_P_((DATASOURCE ds, DSVAR dsvar, ADDRESS argblock));
- void DestroyList V_P_((LNKLST *list));
- DSVAR GetDsvByName V_P_((LNKLST *list, char *dsname, char *dsvname));
- int RemapDsvars V_P_((OBJECT sd, LNKLST *from, LNKLST *to));
- void RebindToggleInputs V_P_((LNKLST *list, OBJECT dq));
- int HandleIterInput V_P_((OBJECT Client, EVENT_REQUEST Request,
- int Label, OBJECT Loc, ADDRESS Args));
- int HandleMainMenu V_P_((OBJECT Client, EVENT_REQUEST Request,
- int Label, OBJECT Loc, ADDRESS Args));
- void StartEndEventReqs V_P_((void));
- int main V_P_((int argc, char *argv[]));
-
-
- /*-----------
- * GetDsVars -- Designed to be called by the TdlForEachVar() traversal
- * function, this will creates a linked list of LNKLST structures
- * which stores various bits of information about the dsvar and
- * the data source name. These lists are used later on for remapping.
- */
- ADDRESS
- GetDsVars (ds, dsvar, argblock)
- DATASOURCE ds;
- DSVAR dsvar;
- ADDRESS argblock;
- {
- LNKLST **head = (LNKLST **) argblock;
- LNKLST *new_item;
-
- new_item = (LNKLST *) S_ALLOC (sizeof (LNKLST));
- new_item->dsname = TdsGetName (ds);
- new_item->dsvname = TdsvGetName (dsvar);
- new_item->dsvar = dsvar;
- new_item->mapped = (float) NO;
- new_item->oldmap = (float) NO;
- new_item->next = *head;
- *head = new_item;
-
- return V_CONTINUE_TRAVERSAL;
- }
-
-
- /*-------------
- * DestroyList -- Traverses linked list, freeing allocated memory
- */
- void
- DestroyList (list)
- LNKLST *list;
- {
- LNKLST *next;
- while (list)
- {
- next = list->next;
- S_FREE ((ADDRESS) list);
- list = next;
- }
- }
-
-
- /*--------------
- * GetDsvByName -- Traverses list and returns the DSVAR
- * that matches both the data source name and data
- * source variable name. The data source name is
- * optional: if it is NULL, then the first DSVAR in
- * the list that matches dsname is returned. Returns
- * NULL if no match is found.
- */
- DSVAR
- GetDsvByName (list, dsname, dsvname)
- LNKLST *list;
- char *dsname;
- char *dsvname;
- {
- for (; list != (LNKLST *) NULL; list = list->next)
- if ((dsname && !strcmp (dsname, list->dsname) &&
- !strcmp (dsvname, list->dsvname)) ||
- (!strcmp (dsvname, list->dsvname)))
- return list->dsvar;
- return (DSVAR) NULL;
- }
-
-
- /*------------
- * RemapDsvars -- This function checks the map bindings for
- * each data source variable in the 'from' list. If the
- * mappings have changed, it then either maps them to the
- * 'to' list of dsvars (mapped == YES), or it unmaps them
- * so they use their local data source (mapped == NO). It
- * returns a boolean value of YES or NO whether or not any
- * mapping was done.
- *
- * Note that in this example program 'from' will be the
- * list from the subdrawings, 'to' is from the main view.
- */
- int
- RemapDsvars (sd, from, to)
- OBJECT sd;
- LNKLST *from;
- LNKLST *to;
- {
- int RemapResult = NO;
-
- for (; from != (LNKLST *) NULL; from = from->next)
- if (from->mapped != from->oldmap)
- {
- RemapResult = YES;
- if (from->mapped == (float) YES)
- /* Map the dsvar to get its values from top level dsvar */
- VOsdSetDsvMapping (sd, from->dsvar,
- GetDsvByName (to, from->dsname, from->dsvname));
- else
- /* Unmap the dsvar to get its values from its local data source */
- VOsdSetDsvMapping (sd, from->dsvar, (DSVAR) NULL);
- from->oldmap = from->mapped;
- }
- return RemapResult;
- }
-
-
- /*-------------------
- * RebindToggleInputs -- This function gets the text toggle
- * input objects (which toggle between 'Local' and 'Global')
- * and the polygon 'arrow' objects (which have visibility
- * dynamics attached to them and are used to visually
- * indicate the relationship between dsvars when mapping is
- * 'Global'), and rebinds them to the 'mapped' field for each
- * dsvar. It also adds each arrow polygon to the dq object
- * that is passed in (see comment below in main() about the
- * ArrowDq). Handles to the text toggle objects and the arrow
- * objects are gotten by adding either a '.map' or '.arrow'
- * extension to the dsvar's name and using that name in
- * TdrGetNamedObject();
- */
- void
- RebindToggleInputs (list, dq)
- LNKLST *list;
- OBJECT dq;
- {
- int NumVars;
- char objname[32];
- ADDRESS *VarList;
- OBJECT object;
- VARDESC vdp;
-
- for (list = list; list != (LNKLST *) NULL; list = list->next)
- {
- /* Rebind to toggle input objects first */
- strcpy (objname, list->dsvname);
- strcat (objname, ".map");
- object = TdrGetNamedObject (MainDrawing, objname);
- if (object)
- {
- VOinGetVarList (object, &VarList, &NumVars);
- TvdPutBuffer (VarList[0], (ADDRESS) & (list->mapped));
- }
-
- /* Rebind to 'arrow' dynamic polygon objects next */
- strcpy (objname, list->dsvname);
- strcat (objname, ".arrow");
- object = TdrGetNamedObject (MainDrawing, objname);
- if (object)
- {
- vdp = VOvdGetVdp (VOttVd (VOdyGetDataObj (VOobDyGet (object),
- V_DYN_VISIBILITY,
- 1)));
- TvdPutBuffer (vdp, (ADDRESS) & (list->mapped));
- VOdqAdd (dq, TOP, object);
- }
- }
- }
-
-
- /*----------------
- * HandleIterInput -- This routine is called by the Event Handler
- * when the user picks on one of the two text input objects
- * that control the 'Start' and 'End' iterations. It
- * activates the input object and draws a border around it.
- * When the user is finished, the border is erased, and some
- * checking is done for reasonable values for the start and
- * end iterations. Also, if the user has gone backwards in
- * the iteration, the data source is reset, or if the user
- * has skipped some iterations, the data source is read
- * until it matches the start iteration.
- */
- /*ARGSUSED*/
- int
- HandleIterInput (Client, Request, Label, Loc, Args)
- OBJECT Client;
- EVENT_REQUEST Request;
- int Label;
- OBJECT Loc;
- ADDRESS Args;
- {
- int i, oldstart, newstart, oldend, newend, er;
- char *CurrValue, OldStart[ITER_BUFSIZE], OldEnd[ITER_BUFSIZE];
- OBJECT location, inp, border;
- WINEVENT *we;
-
- if (Label == START_INPUT)
- {
- CurrValue = start_iter;
- border = StartBorder;
- inp = StartTxtInp;
- }
- else
- {
- CurrValue = end_iter;
- border = EndBorder;
- inp = EndTxtInp;
- }
-
- /* Save the old values */
- oldstart = atoi (start_iter);
- strcpy (OldStart, start_iter);
- oldend = atoi (end_iter);
- strcpy (OldEnd, end_iter);
-
- TdpDrawObject (MainDp, border);
- VOinState (inp, ACTIVE);
-
- /* Set new value to be nothing */
- CurrValue[0] = '\0';
- TdpDrawNextObject (MainDp, inp);
-
- FOREVER
- {
- location = VOloWinEventPoll (V_WAIT);
- switch (VOloType (location))
- {
- case V_EXPOSE:
- TscRedraw (MainScreen, VOloRegion (location));
- strcpy (start_iter, "");
- TdpDrawObject (MainDp, inp);
- TdpDrawObject (MainDp, border);
- break;
-
- case V_RESIZE:
- TscReset (MainScreen);
- StartEndEventReqs ();
- VOinState (inp, ACTIVE);
- break;
-
- case V_KEYPRESS:
- we = (WINEVENT *) VOloWinEventGet (location);
- if (Label == START_INPUT)
- {
- we->loc.x = StartFocus.x;
- we->loc.y = StartFocus.y;
- }
- else
- {
- we->loc.x = EndFocus.x;
- we->loc.y = EndFocus.y;
- }
-
- TloWinEventSetup (location, we, MainScreen, MainDp);
- break;
- }
-
- er = VUerHandleLocEvent (location);
- if (er == INPUT_DONE)
- break;
- else if (er == TERMINATE)
- return TERMINATE;
- }
-
- /* User has hit a return, restore old value */
- if (strlen (CurrValue) == 0)
- {
- strcpy (CurrValue, OldStart);
- TdpDrawNextObject (MainDp, inp);
- }
-
- /* Tidy programmers that we are, let's clean up after ourselves... */
- TdpEraseObject (MainDp, border);
- VOinState (inp, INACTIVE);
-
- /* Let's check the iterations for some reasonable values... */
- newstart = atoi (start_iter);
- newend = atoi (end_iter);
-
- /* NG, so reset the values... */
- if (newend <= newstart)
- {
- strcpy (start_iter, OldStart);
- TdpDrawNextObject (MainDp, StartTxtInp);
- strcpy (end_iter, OldEnd);
- TdpDrawNextObject (MainDp, EndTxtInp);
- }
-
- /*
- * User wants to rewind data, so close and reopen the data source
- * and read up to just before the new start iteration.
- */
- if (newstart < oldstart)
- {
- TviCloseData (MainView);
- TviOpenData (MainView);
- for (i = 0; i < newstart - 1; i++)
- TviReadData (MainView);
- }
- else if ((newstart - oldend) > 1)
- for (i = oldend; i < newstart - 1; i++)
- TviReadData (MainView);
-
- return INPUT_USED;
- }
-
- /*----------------
- * HandleMainMenu -- Handles the 'Quit', 'Restart' and 'Run' buttons.
- */
- int
- HandleMainMenu (Client, Request, Label, Loc, Args)
- OBJECT Client;
- EVENT_REQUEST Request;
- int Label;
- OBJECT Loc;
- ADDRESS Args;
- {
- int i, start, end, diff;
- int remap1, remap2;
- LNKLST *list;
-
- switch (MainSelection)
- {
- case RUN_BUTTON:
- /*
- * Call RemapDsvars to make sure mappings are up to date. If
- * some mapping has occurred, we need to redraw the drawport
- * for the new mappings to take effect.
- */
- remap1 = RemapDsvars (Sd1, Sd1DsvList, MainDsvList);
- remap2 = RemapDsvars (Sd2, Sd2DsvList, MainDsvList);
- if (remap1 || remap2)
- TdpDraw (MainDp);
-
- /*
- * Now iterate the number of times as specified by start_iter
- * and end_iter, reading data each time and updating both the
- * dynamic subdrawings and the 'Start' and 'End' input objects.
- */
- start = atoi (start_iter);
- end = atoi (end_iter);
- diff = end - start;
-
- for (i = 0; i < diff; i++)
- {
- /* Update start and end variables for the start and end
- input objects to reflect this run */
- sprintf (start_iter, "%d", ++start);
- sprintf (end_iter, "%d", ++end);
-
- /* Do the read and update the screen. The routine will
- TdpDrawNext will update the changes made to the start
- and end input object variables. */
- TviReadData (MainView);
- TdpDrawNext (MainDp);
- }
-
- /*
- * Set next iteration interval to be 1 more that what was just
- * down, i.e. 1-10 => 11-20, not 10-19
- */
- sprintf (start_iter, "%d", ++start);
- TdpDrawNextObject (MainDp, StartTxtInp);
- sprintf (end_iter, "%d", (++end));
- TdpDrawNextObject (MainDp, EndTxtInp);
- break;
-
- case RESTART_BUTTON:
- /*
- * Set main view's and subdrawing's dsvars to be local, unmap
- * them, and set their initial values to be 0.0
- */
- for (list = Sd1DsvList; list != (LNKLST *) NULL; list = list->next)
- {
- list->mapped = (float) NO;
- list->oldmap = (float) NO;
- VOsdSetDsvMapping (Sd1, list->dsvar, (DSVAR) NULL);
- TdsvSetValue (list->dsvar, (double) 0.0, 0, 0);
- }
- for (list = Sd2DsvList; list != (LNKLST *) NULL; list = list->next)
- {
- list->mapped = (float) NO;
- list->oldmap = (float) NO;
- VOsdSetDsvMapping (Sd2, list->dsvar, (DSVAR) NULL);
- TdsvSetValue (list->dsvar, (double) 0.0, 0, 0);
- }
- for (list = MainDsvList; list != (LNKLST *) NULL; list = list->next)
- TdsvSetValue (list->dsvar, (double) 0.0,(int)0, (int)0);
-
- strcpy (start_iter, "1");
- strcpy (end_iter, "10");
-
- /* Well, lets restart everything... */
- TviCloseData (MainView);
- TviOpenData (MainView);
- TdpDraw (MainDp);
- break;
-
- case QUIT_BUTTON:
- DestroyList (MainDsvList);
- DestroyList (Sd1DsvList);
- DestroyList (Sd2DsvList);
- TdpDestroy (MainDp);
- TviDestroy (MainView);
- TscCloseCurrentScreen ();
- TTerminate ();
- return TERMINATE;
- }
-
- return INPUT_USED;
- }
-
-
- /*--------------------
- * StartEndEventReqs -- Post rectangle edge event requests for the
- * area around the text input objects. The text
- * input objects represent start and end iterations
- * respectively. The event requests will be
- * reposted when a resize event occurs.
- */
- void
- StartEndEventReqs ()
- {
- RECTANGLE area, delta;
-
- /*
- * Obtain the bounding box of the starting iteration
- * text input object. Use this area to post an inside
- * edge event request and identify the left mouse key
- * as the selection key.
- */
- VOobBox (StartTxtInp, &area, &delta);
- TdpWorldToScreen (MainDp, &area.ll, &area.ll);
- TdpWorldToScreen (MainDp, &area.ur, &area.ur);
- VUerRectEdgePost ((OBJECT) 1, HandleIterInput,
- NULL, 0, &area, V_INSIDE, "\001", START_INPUT);
-
- /*
- * Calculate the text focus point so that the pointer does not
- * need to be in the text entry input object when entering text.
- * Also, deactivate the input object until it is selected.
- */
- StartFocus.x = (area.ll.x + area.ur.x) / 2;
- StartFocus.y = (area.ll.y + area.ur.y) / 2;
- VOinState (StartTxtInp, INACTIVE);
-
- /*
- * Obtain the bounding box of the ending iteration
- * text input object. Use this area to post an inside
- * edge event request and identify the left mouse key
- * as the selection key.
- */
- VOobBox (EndTxtInp, &area, &delta);
- TdpWorldToScreen (MainDp, &area.ll, &area.ll);
- TdpWorldToScreen (MainDp, &area.ur, &area.ur);
- VUerRectEdgePost ((OBJECT) 1, HandleIterInput,
- NULL, 0, &area, V_INSIDE, "\001", END_INPUT);
-
- /*
- * Calculate the text focus point so that the pointer does not
- * need to be in the text entry input object when entering text.
- * Also, deactivate the input object until it is selected.
- */
- EndFocus.x = (area.ll.x + area.ur.x) / 2;
- EndFocus.y = (area.ll.y + area.ur.y) / 2;
- VOinState (EndTxtInp, INACTIVE);
- }
-
-
- /*
- * MAIN PROGRAM
- */
- int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
- LPSTR lpCmdLine, int nCmdShow )
- {
- INT argc = 0;
- CHAR **argv;
- /*
- * program arguments
- * argv[1] - display device name (default is to use DVDEVICE)
- */
-
- /* Define & initialize device name and view filename */
- char *device_name = DVDEVICE; /* default device name */
- char *view_name = VIEW_NAME; /* default view name */
-
- int NumVars, er;
- OBJECT ArrowDq, loc, tmpobj;
- ADDRESS *VarList;
- RECTANGLE area, delta;
-
- /*--------------------
- * Initialization
- *
- * TInit: perform the initialization of DV-Tools
- * TInit reads your configuration file and any
- * environment variables or logical names set.
- */
- make_argv(&argc,&argv,GetCommandLine());
- TInit( DVPATH, DISPFORMS_STB );
-
- /*
- * TscOpenSet: open a device as a screen object using
- * specified attributes
- * TscErase: erase the entire screen in the default
- * background color
- *
- * Set exposure block to YES to insure the window
- * is ready for drawing when TdpDraw is called.
- */
- if (argc > 1)
- device_name = argv[1];
- MainScreen = TscOpenSet (device_name, DVCOLORTABLE,
- V_X_EXPOSURE_BLOCK, YES,
- V_ACTIVE_CURSOR, V_END_OF_LIST);
- if (!MainScreen)
- {
- printf ("Must specify device on command line or");
- printf (" in DataViews configuration file.\n");
- S_EXIT (EXIT_ERR);
- }
-
- /*
- * VOscWinEventMask: sets the screen's window event mask
- */
- VOscWinEventMask ((ULONG) V_KEYPRESS | V_BUTTONPRESS | V_MOTIONNOTIFY
- | V_EXPOSE | V_RESIZE,
- (ULONG) 0);
-
- /*
- * TviLoad: Load a view in from a file,
- * the view dyn_sd.v
- */
- MainView = TviLoad (view_name);
- if (!MainView)
- {
- printf ("Could not load view from file ");
- printf ("%s.\n", view_name);
- S_EXIT (EXIT_ERR);
- }
-
- /*
- * Get a view's drawing object and create drawports based on
- * defined areas.
- */
- MainDrawing = TviGetDrawing (MainView);
- tmpobj = TdrGetNamedObject (MainDrawing, "main.area");
- VOobBox (tmpobj, &area, &delta);
- MainDp = TdpCreateStretch (MainScreen, MainView, SCREEN_VIEWPORT, &area);
-
- /*
- * Rebind and set up event handling for 'Quit,' 'Run,' and `Restart' menu.
- */
- tmpobj = TdrGetNamedObject (MainDrawing, "run.menu");
- VOinGetVarList (tmpobj, &VarList, &NumVars);
- TvdPutBuffer (VarList[0], (ADDRESS) & MainSelection);
- VPvdtype ((VARDESC) VarList[0], V_I_TYPE);
- VUerServiceResultPost ((OBJECT) 1, HandleMainMenu,
- NULL, 0, tmpobj, INPUT_DONE, (int)1);
-
- /*
- * Get a handle to two text input objects and rebind them to global
- * program buffers (set the vdp type and dimensions to be thorough). Then
- * then set their default values.
- * Next, deactivate them from accepting input and set up an event handler
- * to handle them when the user selects on either object with the left
- * mouse button. In this case, the events are based on the particular area
- * on the screen occupied by the input objects.
- * And one final touch, the view contains rectangle objects around each
- * of these input objects which are to be drawn when the user has selected
- * the object and erased when done. These objects are deleted from the
- * drawing (Note that first their reference count is increased so they are
- * not automatically destroyed when removed from the drawing). They are
- * then drawn and erased separately as needed by the function
- * HandleIterInput().
- */
- StartTxtInp = TdrGetNamedObject (MainDrawing, "start");
- VOinGetVarList (StartTxtInp, &VarList, &NumVars);
- TvdPutBuffer (VarList[0], start_iter);
- VPvdtype ( VarList[0], V_T_TYPE);
- VPvddim ((VARDESC) VarList[0], (int)1, (int)1, (int)ITER_BUFSIZE);
- strcpy (start_iter, "1");
-
- /* Get border rectangle object */
- StartBorder = TdrGetNamedObject (MainDrawing, "start.border");
- VOobReference(StartBorder);
- VOdrObDelete (MainDrawing, StartBorder);
-
- /* Now do the same thing for 'End' input object... */
- EndTxtInp = TdrGetNamedObject (MainDrawing, "end");
- VOinGetVarList (EndTxtInp, &VarList, &NumVars);
- TvdPutBuffer (VarList[0], end_iter);
- VPvdtype ((VARDESC) VarList[0], V_T_TYPE);
- VPvddim ((VARDESC) VarList[0], (int)1, (int)1, (int)ITER_BUFSIZE);
- strcpy (end_iter, "10");
-
- EndBorder = TdrGetNamedObject (MainDrawing, "end.border");
- VOobReference (EndBorder);
- VOdrObDelete (MainDrawing, EndBorder);
-
- StartEndEventReqs ();
-
- /*
- * Get a handle to the two subdrawing objects and enable their dynamics
- */
- Sd1 = TdrGetNamedObject (MainDrawing, "sd1");
- VOsdSetDynamicFlag (Sd1, SD_DYN_ENABLED);
- Sd2 = TdrGetNamedObject (MainDrawing, "sd2");
- VOsdSetDynamicFlag (Sd2, SD_DYN_ENABLED);
-
- /*
- * Create three linked lists of data source variables from the two
- * subdrawing objects and the main view.
- */
- MainDsvList = Sd1DsvList = Sd2DsvList = NULL;
- TdlForEachVar (TviGetDataSourceList (MainView),
- (TDLFOREACHDSVFUNPTR)GetDsVars, (ADDRESS) & MainDsvList);
- TdlForEachVar (TviGetDataSourceList (VOsdViGet (Sd1)),
- (TDLFOREACHDSVFUNPTR)GetDsVars, (ADDRESS) & Sd1DsvList);
- TdlForEachVar (TviGetDataSourceList (VOsdViGet (Sd2)),
- (TDLFOREACHDSVFUNPTR)GetDsVars, (ADDRESS) & Sd2DsvList);
-
- /*
- * ArrowDq is a container object which will hold the arrow
- * polygon objects. These objects have visibility dynamics
- * attached to them, and as such, they need to have their
- * dynamics updated using TdpDrawNext() or TdpDrawNextObject().
- * TdpDrawNextObject() is used here because we do not want any
- * of the subdrawings to update, so by creating a single container
- * object, we can isolate which dynamics we want updated.
- */
- ArrowDq = VOdqCreate (INITIAL_DQ_SIZE);
-
- /*
- * Bind the toggle input objects and the dynamic arrows to each dsvar's
- * 'mapped' field in the linked list structure. This routine also adds
- * the arrow objects to the ArrowDq.
- */
- RebindToggleInputs (Sd1DsvList, ArrowDq);
- RebindToggleInputs (Sd2DsvList, ArrowDq);
-
- TviOpenData (MainView);
- TscErase (MainScreen);
- TdpDraw (MainDp);
-
- FOREVER
- {
- /* Poll the cursor */
- loc = VOloWinEventPoll (V_WAIT);
- switch (VOloType (loc))
- {
- case V_BUTTONPRESS:
- case V_KEYPRESS:
- /* Update any arrows that may have changed and pass the location object
- | onto the event handler */
- er = VUerHandleLocEvent (loc);
- if (er != TERMINATE)
- TdpDrawNextObject (MainDp, ArrowDq);
- break;
-
- case V_EXPOSE:
- TscRedraw (MainScreen, VOloRegion (loc));
- break;
-
- case V_RESIZE:
- /* We don't redraw the screen since every V_RESIZE event
- | will be followed by a V_EXPOSE event */
- TscReset (MainScreen);
- StartEndEventReqs ();
- break;
- }
- if (er == TERMINATE)
- break;
- }
- return EXIT_OK;
- }
-